<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/10/4 0004
  Time: 21:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fnt" uri="http://java.sun.com/jsp/jstl/functions" %>
<link rel="stylesheet" type="text/css" href="/manage/css/static/question-type/mymian.css"/>
<link rel="stylesheet" type="text/css" href="/manage/css/static/h-ui/css/H-ui.min.css" />
<!--_footer 作为公共模版分离出去-->
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/manage/js/lib/laypage/1.2/laypage.js"></script>
<span class="r">共有数据：<strong>${userInfoCount}</strong> 条</span>
<table class="table table-border table-bordered table-bg table-hover table-sort">
    <thead>
    <tr class="text-c">
        <th>ID</th>
        <th>用户账号</th>
        <th>性别</th>
        <th>真实姓名</th>
        <th>学历</th>
        <th>岗位</th>
        <th>联系方式</th>
        <th>注册时间</th>
        <th>用户状态</th>
        <th>是否可用</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${pageInfo.list}" var="userInfo" varStatus="stat">
        <tr class="text-c" style="text-align: center;">
            <td>${userInfo.id}</td>
            <td class="text-l">
                <a class="user-message">${userInfo.email}</a>
            </td>
            <input type="hidden" value="${userInfo.area}">
            <input type="hidden" value="<f:formatDate value="${userInfo.birthday}" pattern="yyyy-MM-dd"></f:formatDate>">
            <td>${userInfo.sex}</td>
            <td>${userInfo.userName}</td>
            <td>${userInfo.education.educationName}</td>
            <td>${userInfo.post.postName}</td>
            <td>${userInfo.phone}</td>
            <td>
                <f:formatDate value="${userInfo.creatTime}" pattern="yyyy-MM-dd"></f:formatDate>
            </td>
            <td class="status-user">
               <c:if test="${userInfo.vipUser == 0}">
                   普通用户
               </c:if>
                <c:if test="${userInfo.vipUser == 1}">
                    待审核
                </c:if>
                <c:if test="${userInfo.vipUser == 2}">
                    审核未通过
                </c:if>
                <c:if test="${userInfo.vipUser == 3}">
                    内测用户
                </c:if>
            </td>
            <td class="td-status">
                <c:if test="${userInfo.enable}" var="isCur">
                    <span class="label label-success radius">已启用</span>
                </c:if>
                <c:if test="${not isCur}">
                    <span class="label label-default radius">已禁用</span>
                </c:if>
            </td>
            <td class="f-14 td-manage">
                <c:if test="${userInfo.vipUser == 0}">
                    <a style="text-decoration:none" onClick="article_shenhe(this,'${userInfo.id}')" href="javascript:;" title="审核">审核</a>
                </c:if>
                <c:if test="${userInfo.vipUser == 1}">
                    <a style="text-decoration:none" onClick="article_shenhe(this,'${userInfo.id}')" href="javascript:;" title="审核">审核</a>
                </c:if>
                <c:if test="${userInfo.vipUser == 2}">
                    <a style="text-decoration:none" onClick="article_shenhe(this,'${userInfo.id}')" href="javascript:;" title="复核">复核</a>
                </c:if>
                <c:if test="${userInfo.vipUser == 3}">
                    <a style="text-decoration:none" onClick="article_start(this,'${userInfo.id}')" href="javascript:;" title="降级">降级</a>
                </c:if>
                <a style="text-decoration:none" class="ml-5" onClick="article_edit('用户考试记录','/manage/user-info/test-pager?userId=${userInfo.id}','${userInfo.id}')" href="javascript:;" title="编辑">
                    <i class="Hui-iconfont">&#xe6df;</i>
                </a>
                <a style="text-decoration:none" class="ml-5" onClick="article_del(this,'${userInfo.id}')" href="javascript:;" title="删除">
                    <i class="Hui-iconfont">&#xe631;</i>
                </a>
            </td>
        </tr>
    </c:forEach>
    </tbody>
</table>
<div class="list-page">
    <a href="/manage/user-info/user-info-list-page?pageNum=${pageInfo.prePage}" data="${pageInfo.prePage}">上一页</a>
    <c:forEach items="${pageInfo.navigatepageNums}" var="i">
        <c:if test="${pageInfo.pageNum eq i}" var="isCur">
            <span class="current">${i}</span>
        </c:if>
        <c:if test="${not isCur}">
            <a href="#" data="${i}">${i}</a>
        </c:if>
    </c:forEach>
    <a href="/manage/user-info/user-info-list-page?pageNum=${pageInfo.nextPage}" data="${pageInfo.nextPage}">下一页</a>
</div>
<script>
    //鼠标上去，显示全部信息
    $(".user-message").click(function () {
        var id=$(this).parent().prev().html();
        var email=$(this).html();
        var area=$(this).parent().next().val();
        var birthday=$(this).parent().next().next().val();
        var sex=$(this).parent().next().next().next().html();
        var userName=$(this).parent().next().next().next().next().html();
        var education=$(this).parent().next().next().next().next().next().html();
        var post=$(this).parent().next().next().next().next().next().next().html();
        var phone=$(this).parent().next().next().next().next().next().next().next().html();
        var date=$(this).parent().next().next().next().next().next().next().next().next().html();
        var vipUser=$(this).parent().next().next().next().next().next().next().next().next().next().html();
        var stat=$(this).parent().next().next().next().next().next().next().next().next().next().next().children().html();
        layer.open({
            type: 1,
            area: ['500px'],
            fix: false, //不固定
            maxmin: true,
            shade:0.4,
            title: '查看用户详情信息',
            content: '<p>用户姓名:'+userName+'</p>' +
                '<p>用户ID:'+id+'</p>'+
                '<p>用户账号:'+email+'</p>'+
                '<p>用户性别:'+sex+'</p>' +
                '<p>用户生日:'+birthday+'</p>' +
                '<p>用户地区:'+area+'</p>' +
                '<p>联系方式:'+phone+'</p>' +
                '<p>用户学历:'+education+'</p>' +
                '<p>用户岗位:'+post+'</p>' +
                '<p>注册时间:'+date+'</p>' +
                '<p>用户状态:'+vipUser+'</p>' +
                '<p>是否可用:'+stat+'</p>'
        });
    });

    /*资讯-添加*/
    function article_add(title,url,w,h){
        var index = layer.open({
            type: 2,
            title: title,
            content: url
        });
        layer.full(index);
    }
    /*资讯-编辑*/
    function article_edit(title,url,id,w,h){
        var index = layer.open({
            type: 2,
            title: title,
            content: url
        });
        layer.full(index);
    }
    /*用户-删除*/
    function article_del(obj,id){
        layer.confirm('确认要禁用或者启用吗？',function(index){
            var data={id:id};
            $.ajax({
                type: 'POST',
                url: '/manage/user-info/update-user',
                data:data,
                success: function(data){
                    layer.msg('已修改!',{icon:1,time:1000});
                }
            });
        });
    }

    /*用户-审核*/
    function article_shenhe(obj,id){
        layer.confirm('审核用户？', {
                btn: ['通过','不通过','取消'],
                shade: false,
                closeBtn: 0
            },
            function(){
                var userState=3;
                var data={id:id,userState:userState};
                $.ajax({
                    url:"/manage/user-info/pass-user",
                    type:"get",
                    data:data,
                    async:true,
                    success:function (mes) {
                        $(obj).parents("tr").find(".td-manage").prepend('<a class="c-primary" onClick="article_start(this,'+id+')" href="javascript:;" title="用户降级">用户降级</a>');
                        $(obj).parents("tr").find(".status-user").html('<span class="label label-success radius">内测用户</span>');
                        $(obj).remove();
                        layer.msg('内测用户', {icon:6,time:1000});
                    }
                });
            },
            function(){
                var userState=2;
                var data={id:id,userState:userState};
                $.ajax({
                    url:"/manage/user-info/pass-user",
                    type:"get",
                    data:data,
                    async:true,
                    success:function (mes) {
                        $(obj).parents("tr").find(".td-manage").prepend('<a class="c-primary" onClick="article_shenhe(this,'+id+')" href="javascript:;" title="申请复核">申请复核</a>');
                        $(obj).parents("tr").find(".status-user").html('<span class="label label-danger radius">审核未通过</span>');
                        $(obj).remove();
                        layer.msg('未通过', {icon:5,time:1000});
                    }
                });
            });
    }

    /*资讯-发布*/
    function article_start(obj,id){
        layer.confirm('确认要降为普通用户吗？',function(index){
            var userState=0;
            var data={id:id,userState:userState};
            $.ajax({
                url:"/manage/user-info/pass-user",
                type:"get",
                data:data,
                async:true,
                success:function (mes) {
                    $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="article_shenhe(this,'+id+')" href="javascript:;" title="降级"><i class="Hui-iconfont">&#xe6de;</i></a>');
                    $(obj).parents("tr").find(".status-user").html('<span class="label label-success radius">普通用户</span>');
                    $(obj).remove();
                    layer.msg('已发布!',{icon: 6,time:1000});
                }
            });

        });
    }
</script>